-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Better names of and more compatibility between ad hoc intersections of instances #18506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: pyodide (https://github.com/pyodide/pyodide)
- src/py/pyodide/_state.py:21: error: Incompatible types in assignment (expression has type "pyodide._state.<subclass of "ModuleType" and "JsProxy">1", target has type "pyodide._state.<subclass of "ModuleType" and "JsProxy">") [assignment]
- src/py/pyodide/_state.py:21: error: Incompatible types in assignment (expression has type "pyodide._state.<subclass of "ModuleType" and "JsProxy">2", target has type "pyodide._state.<subclass of "ModuleType" and "JsProxy">") [assignment]
|
ilevkivskyi
approved these changes
Jan 22, 2025
Thanks! |
x612skm
pushed a commit
to x612skm/mypy-dev
that referenced
this pull request
Feb 24, 2025
…f instances (python#18506) While working on python#18433, we encountered [this bug.](python#18433 (comment)). @ilevkivskyi identified [the underlying problem](python#18433 (comment)), and we decided to try to reuse previously created ad hoc intersections of instances instead of always creating new ones. While working on this PR, I realised that reusing intersections requires more complete names. Currently, module and type variable specifications are not included, which could result in mistakes when using these names as identifiers. So, I switched to more complete names. Now, for example, `<subclass of "A" and "A">` becomes `<subclass of "mod1.A[builtins.int]" and "mod2.A">`. Hence, I had to adjust many existing test cases where `reveal_type` is used. `testReuseIntersectionForRepeatedIsinstanceCalls` confirms that the mentioned bug is fixed. `testIsInstanceAdHocIntersectionIncrementalNestedClass` and `testIsInstanceAdHocIntersectionIncrementalUnions` are in a separate commit. I think they are not really necessary, so we might prefer to remove them. I added them originally because I had to adjust `lookup_fully_qualified` a little. The change is very simple, but I could not create a test case where it is not sufficient. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on #18433, we encountered this bug.. @ilevkivskyi identified the underlying problem, and we decided to try to reuse previously created ad hoc intersections of instances instead of always creating new ones.
While working on this PR, I realised that reusing intersections requires more complete names. Currently, module and type variable specifications are not included, which could result in mistakes when using these names as identifiers.
So, I switched to more complete names. Now, for example,
<subclass of "A" and "A">
becomes<subclass of "mod1.A[builtins.int]" and "mod2.A">
. Hence, I had to adjust many existing test cases wherereveal_type
is used.testReuseIntersectionForRepeatedIsinstanceCalls
confirms that the mentioned bug is fixed.testIsInstanceAdHocIntersectionIncrementalNestedClass
andtestIsInstanceAdHocIntersectionIncrementalUnions
are in a separate commit. I think they are not really necessary, so we might prefer to remove them. I added them originally because I had to adjustlookup_fully_qualified
a little. The change is very simple, but I could not create a test case where it is not sufficient.